home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / STUTTGART / LANG / C / LIB / UNIXLIB37B / !UnixLib37 / src / clib / sys / h / tty < prev    next >
Text File  |  1996-11-09  |  2KB  |  84 lines

  1. /****************************************************************************
  2.  *
  3.  * $Source: /unixb/home/unixlib/source/unixlib37/src/clib/sys/h/RCS/tty,v $
  4.  * $Date: 1996/11/06 22:01:41 $
  5.  * $Revision: 1.3 $
  6.  * $State: Rel $
  7.  * $Author: unixlib $
  8.  *
  9.  * $Log: tty,v $
  10.  * Revision 1.3  1996/11/06 22:01:41  unixlib
  11.  * Yet more changes by NB, PB and SC.
  12.  *
  13.  * Revision 1.2  1996/10/30 22:04:51  unixlib
  14.  * Massive changes made by Nick Burret and Peter Burwood.
  15.  *
  16.  * Revision 1.1  1996/04/19 21:23:56  simon
  17.  * Initial revision
  18.  *
  19.  ***************************************************************************/
  20.  
  21. #ifndef __SYS_TTY_H
  22. #define __SYS_TTY_H
  23.  
  24. #ifndef __TERMIO_H
  25. #include <termio.h>
  26. #endif
  27.  
  28. #define __TTY_STATIC_BUFS
  29.  
  30. #ifdef __TTY_STATIC_BUFS
  31. /* #error static tty bufs not implemented completely */
  32. #ifndef __SYS_PARAM_H
  33. #include <sys/param.h>
  34. #endif
  35. #endif
  36.  
  37. #ifdef __cplusplus
  38. extern "C" {
  39. #endif
  40.  
  41. #define MAXTTY    2
  42.  
  43. #define TTY_CON 0
  44. #define TTY_423 1
  45.  
  46. struct tty
  47.   {
  48.   struct termio t[1];
  49.   struct winsize w[1];
  50.   int (*out)(int);
  51.   int (*in)(void);
  52.   int (*scan)(int);
  53.   int (*init)(void);
  54.   int (*flush)(void);
  55. #ifdef __TTY_STATIC_BUFS
  56.   int sx,cx;        /* screen x, character x */
  57.   int cnt;              /* number of characters in input buffer */
  58.   char *ptr;            /* read pointer in input buffer */
  59.   char buf[MAX_INPUT];  /* input buffer */
  60.   char del[MAX_INPUT];  /* number of displayed characters for character cx */
  61. #else
  62.   char *buf, *ptr;
  63.   int cnt;              /* number of characters in input buffer */
  64.   char *del;
  65.   int sx,cx;        /* screen x, character x */
  66. #endif
  67.   };
  68.  
  69. /* Note, the buf and del buffers are declared statically in the tty struct.
  70.    This is so that an exec'd process which shares the tty struct doesn't
  71.    free something allocated by the parent process.  Such a call to free would
  72.    confuse the memory allocation system since the buffer wouldn't have been
  73.    allocated by that process but by the parent process.  We could check the
  74.    address of the buffer agains __lomem and __break, but we might aswell
  75.    just live with the statically allocated memory compared to the extra code
  76.    we would need to have.  Lazy, probably, but it works okay and only costs
  77.    MAXTTY * MAX_INPUT * 2 (= 1024 bytes in current implementation).  */
  78.  
  79. #ifdef __cplusplus
  80.     }
  81. #endif
  82.  
  83. #endif
  84.